package com.example.other;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class ThreeSum {
    public static void main(String[] args) {

    }


    public List<List<Integer>> threeSum(int[] nums) {
        List<Integer> tmp = new ArrayList<>();
        List<List> result = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            int[] ints = new int[nums.length - 1];
            for (int j = 0; j < nums.length - 1; j++) {
                if (i != j) {
                    ints[j] = nums[i];
                }
            }
            int[] ints1 = twoSum(ints, nums[i]);
            if (ints1 != null) {
//                Collections.addAll(tmp, ints1);
            }

        }

        return null;

    }

    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (map.get(target - nums[i]) != null && map.get(target - nums[i]) != i) {
                return new int[]{nums[i], target - nums[i]};
            }
            map.put(nums[i], i);
        }
        return null;
    }

}
